package org.usyk.util;

import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: Алексейка
 * Date: 04.03.12
 * Time: 12:54
 * To change this template use File | Settings | File Templates.
 */
public class StringUtil {
    
    public static String convertFromCoalitionRepresentation(Set<Integer> coalition) {
        StringBuilder result = new StringBuilder("0000000000");
        for (Integer i : coalition) {
            result.replace(i,i+1,"1");
        }
        return result.toString();
    }
    
    public static int numberOfParties(String coalition){
        int result = 0;
        for (char c : coalition.toCharArray()) {
            if (c=='1') result++;
        }
        return result;
    }

    public static void main(String[] args) {
        Set<Integer> set = new HashSet<Integer>();
        set.add(1);
        set.add(6);
        set.add(8);
        set.add(9);
        System.out.println(convertFromCoalitionRepresentation(set));
        System.out.println(numberOfParties(convertFromCoalitionRepresentation(set)));

    }
    
}
